package com.tutucms.common.data;

import java.io.Serializable;


/**
 * @author WangXuDong
 * @version 1.0
 */
public class KeyValue<K, V> implements Serializable {

    private static final long serialVersionUID = -7666204527208127470L;
    private K key;
    private V value;

    public KeyValue() {
    }

    public KeyValue(K k, V v) {
        this.key = k;
        this.value = v;
    }

    public K getKey() {
        return key;
    }

    public void setKey(K key) {
        this.key = key;
    }

    public V getValue() {
        return value;
    }

    public void setValue(V value) {
        this.value = value;
    }

    @Override
    public String toString() {
        return this.key + ":" + this.value;
    }

    @Override
    public boolean equals(Object obj) {
        if (getClass() == obj.getClass()) {
            @SuppressWarnings("rawtypes")
			KeyValue kv = (KeyValue) obj;
            if (this.key.equals(kv.getKey())
                    && this.value.equals(kv.getValue())) {
                return true;
            }
        }
        return super.equals(obj);
    }

    @Override
    public int hashCode() {
        int result = 17;
        result = 19 * result + this.key.hashCode();
        result = result + 19 * result + this.value.hashCode();
        return result + 37;
    }
}
